package com.hao.wms.mvc;

import com.hao.wms.domain.Permission;
import com.hao.wms.query.QueryObject;
import com.hao.wms.service.IPermissionService;
import com.hao.wms.util.RequiredPermission;

import java.io.IOException;

public class PermissionAction extends BaseAction{
	private Permission permission = new Permission();
	private QueryObject queryObject = new QueryObject();
	private IPermissionService permissionService;
	
	public Permission getPermission() {
		return permission;
	}

	public void setPermission(Permission permission) {
		this.permission = permission;
	}

	

	public QueryObject getQueryObject() {
		return queryObject;
	}

	public void setQueryObject(QueryObject queryObject) {
		this.queryObject = queryObject;
	}


	public void setPermissionService(IPermissionService permissionService) {
		this.permissionService = permissionService;
	}

	@Override
	@RequiredPermission(value="权限列表")
	public String execute() throws Exception {
		putContext(PAGERESULT, permissionService.query(queryObject));
		return LIST;
	}
	@RequiredPermission(value="删除权限")
	public String delete() throws IOException {
		permissionService.delete(permission);
		putResponseText("删除成功");
		return SUCCESS;
	}
	@RequiredPermission(value="重新加载权限")
	public String reload() {
		permissionService.reload();
		return NONE;
	}

}
